$(function() {
    // 显示信息
    var params = JSON.parse(sessionStorage.getItem('hmdj_publish'));
    // 计算截止时间
    var today = new Date(),
        tomorrow = new Date(new Date().getTime() + (1e3 * 60 * 60 * 24)),
        tomorrowDate = new Date(tomorrow),
        month = (tomorrowDate.getMonth() + 1),
        day = (tomorrowDate.getDate()),
        time = '';
    if(today.getHours() >= 0 && today.getHours() < 12) {
        time = '12:00';
    }else {
        time = '24:00';
    }
    $('.endTime').text(month + '月' + day + '日(明天)' + time);
    $('.upPrice').val(params.topPrice);
    $('.downPrice').val(params.botPrice);
});

// 发布商品
$(document).on('click', '.publish-btn', function() {
    var params = JSON.parse(sessionStorage.getItem('hmdj_publish')),
        result = Model.goods.putNewGoods(params);
    if (result.code) {
        Common.fn.formatOutput(result);
        loading.hide();
        return false;
    }
    weui.alert(result.data, function() {
        location.href = '../index.html';
    });
});